from selenium import webdriver
from selenium.webdriver.common.by import By
import time

driver = webdriver.Edge()
driver.get('https://www.baidu.com/')
# id定位,点击登录
driver.find_element(By.ID, 's-top-loginbtn').click()
time.sleep(5)
# class定位，短信登录
# driver.find_element(By.ID,'switch-item activ').click()
# id定位，短信登录
driver.find_element(By.ID,'TANGRAM__PSP_11__changeSmsCodeItem').click()
time.sleep(2)
# name定位，输入账号
driver.find_element(By.NAME, 'username').send_keys('15523615751')
time.sleep(2)
# xpath定位绝对路径，发送验证码
# driver.find_element(By.XPATH,'/html/body/div[5]/div[2]/div[2]/div/div/div/div/div/div[1]/div[2]/div/form/p[2]/button').click()
# time.sleep(15)
# xpath定位相对路径，发送验证码
driver.find_element(By.XPATH,'//*[@id="TANGRAM__PSP_11__smsTimer"]').click()
time.sleep(15)
# selector定位,勾选协议
driver.find_element(By.CSS_SELECTOR, '#TANGRAM__PSP_11__smsIsAgree').click()
time.sleep(2)
# id定位，点击登录
driver.find_element(By.ID,'TANGRAM__PSP_11__smsSubmit').click()
time.sleep(3)

# tag_name定位,输入框
# driver.find_element(By.TAG_NAME, 'input').send_keys('六百六十六')
# LINK_TEXT定位
# driver.find_element(By.LINK_TEXT, '总书记要求这些事“从娃娃抓起”').click()
# PARTIAL_LINK_TEXT定
# driver.find_element(By.PARTIAL_LINK_TEXT定位, '关之琳62岁状态').click()